package com.yiwyn.demo.utils.modify.handle.router.route;

import com.yiwyn.demo.utils.modify.anno.modify.ModifyEventField;
import com.yiwyn.demo.utils.modify.entity.ModifyEntity;
import com.yiwyn.demo.utils.modify.handle.event.base.BaseTypeEvent;
import com.yiwyn.demo.utils.modify.handle.router.base.BaseModifyFieldRoute;

import java.lang.reflect.Field;

public class ModifyEventRoute extends BaseModifyFieldRoute {


    @Override
    public void processField(Field field, ModifyEntity.ModifyItem modifyItem, BaseTypeEvent<?> baseTypeEvent) {
        ModifyEventField modifyFieldEventAnno = field.getAnnotation(ModifyEventField.class);
        String filedType = modifyFieldEventAnno.filedType();
        if (modifyFieldEventAnno.filedType().isEmpty()) {
            filedType = field.getName();
        } else {
            filedType = modifyFieldEventAnno.filedType();
        }
        String eventId = modifyFieldEventAnno.eventId();
        modifyItem.setModifyType(filedType);
        // baseTypeEvent.triggerEvent(eventId, modifyItem);



    }
}
